{extend name="admin@public/main"}
{block name="buttons"}
{if hasAuth('admin/menu/add')}
    <button class = "btn btn-sm btn-outline-primary" data-action="dialog" data-action-url="{:url('admin/menu/add')}" data-dialog-title="新增节点">新增节点</button>
{/if}
{/block}

{block name="content"}
<form class = "data-search-form" method="get">
    <table class = "table">
        <thead>
            <tr class = "title">
                <th>图标</th>
                <th>节点名称</th>
                <th>节点类型</th>
                <th>节点状态</th>
                <th>链接</th>
                <th>排序</th>
                <th>备注</th>
                <th>操作</th>
            </tr>

        </thead>
        {php}$node_types = ['','菜单','按钮','接口'];{/php}
        {php}$node_status = ['','启用','禁用']{/php}
        <tbody>
            {if empty($list)}
            <tr>
                <td colspan = "8" class = "empty-list"><span class = "glyphicon glyphicon-inbox"></span>没有任何记录</td>
            </tr>
            {else}
            {volist name="list" id="vo"}
            <tr>
                <td>{if condition="!empty($vo.icon) and $vo.icon neq '#'"}<i class = "{$vo.icon}"/>{/if}</td>
                <td>{$vo.name}</td>
                <td>{$node_types[$vo.type]}</td>
                <td>{$node_status[$vo.status]}</td>
                <td>{$vo.rule}</td>
                <td>{$vo.sort}</td>
                <td>{$vo.remark}</td>
                <td>
                    {if hasAuth('admin/menu/edit')}
                    <span class="text-explode">|</span>
                    <a class = "user-option" data-action = "dialog" data-action-url="{:url('admin/menu/edit',['id'=>$vo.id])}" >编辑</a>
                    {/if}
                    {if hasAuth('admin/menu/forbid')}
                        <span class="text-explode">|</span>
                        {if condition="$vo.status eq 1"}
                        <a class = "user-option" data-action = "ajax" data-action-method = "post"
                           data-action-url="{:url('admin/menu/forbid')}" data-action-params = '{"id":{$vo.id},"field":"status","value":2}'>禁用</a>
                        {else}
                        <a class = "user-option" data-action = "ajax" data-action-method = "post"
                           data-action-url="{:url('admin/menu/forbid')}"  data-action-params = '{"id":{$vo.id},"field":"status","value":2}'>启用</a>
                        {/if}
                    {/if}
                    {if hasAuth('admin/menu/del')}
                    <span class="text-explode">|</span>
                    <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/del')}" data-action-method = "post"
                       data-action-params = '{"id":{$vo.id},"field":"delete"}' data-action-ask = "是否确定删除节点:{$vo.name}">删除</a>
                    {/if}
                </td>
            </tr>
            {notempty name="vo.sub"}
                {volist name="vo.sub" id="vo1"}
                <tr>
                    <td>{if condition="!empty($vo1.icon) and $vo1.icon neq '#'"}<i class = "{$vo1.icon}"/>{/if}</td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;|--{$vo1.name}</td>
                    <td>{$node_types[$vo1.type]}</td>
                    <td>{$node_status[$vo1.status]}</td>
                    <td>{$vo1.rule}</td>
                    <td>{$vo1.sort}</td>
                    <td>{$vo1.remark}</td>
                    <td>
                        {if hasAuth('admin/menu/edit')}
                        <span class="text-explode">|</span>
                        <a class = "user-option" data-action = "dialog" data-action-url="{:url('admin/menu/edit',['id'=>$vo1.id])}" >编辑</a>
                        {/if}
                        {if hasAuth('admin/menu/forbid')}
                        <span class="text-explode">|</span>
                        {if condition="$vo1.status eq 1"}
                        <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/forbid')}"
                           data-action-params = '{"id":{$vo1.id},"field":"status","value":2}' data-action-method = "post">禁用</a>
                        {else}
                        <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/forbid')}"
                           data-action-params = '{"id":{$vo1.id},"field":"status","value":1}' data-action-method = "post">启用</a>
                        {/if}
                        {/if}
                        {if hasAuth('admin/menu/del')}
                        <span class="text-explode">|</span>
                        <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/del')}"
                           data-action-method = "post" data-action-params = '{"id":{$vo1.id},"field":"delete"}' data-action-ask = "是否确定删除节点:{$vo1.name}">删除</a>
                        {/if}
                    </td>
                </tr>
                {notempty name="vo1.sub"}
                    {volist name="vo1.sub" id="vo2"}
                    <tr>
                        <td>{if condition="!empty($vo2.icon) and $vo2.icon neq '#'"}<i class = "{$vo2.icon}"/>{/if}</td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--{$vo2.name}</td>
                        <td>{$node_types[$vo2.type]}</td>
                        <td>{$node_status[$vo2.status]}</td>
                        <td>{$vo2.rule}</td>
                        <td>{$vo2.sort}</td>
                        <td>{$vo2.remark}</td>
                        <td>
                            {if hasAuth('admin/menu/edit')}
                            <span class="text-explode">|</span>
                            <a class = "user-option" data-action = "dialog" data-dialog-title="编辑节点"  data-action-url="{:url('admin/menu/edit',['id'=>$vo2.id])}" >编辑</a>
                            {/if}
                            {if hasAuth('admin/menu/forbid')}
                            <span class="text-explode">|</span>
                            {if condition="$vo2.status eq 1"}
                            <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/forbid')}"
                               data-action-params = '{"id":{$vo2.id},"field":"status","value":2}' data-action-method = "post">禁用</a>
                            {else}
                            <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/forbid')}"
                               data-action-params = '{"id":{$vo2.id},"field":"status","value":1}' data-action-method = "post">启用</a>
                            {/if}
                            {/if}
                            {if hasAuth('admin/menu/del')}
                            <span class="text-explode">|</span>
                            <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/del')}"
                               data-action-params = '{"id":{$vo2.id},"field":"delete"}'data-action-ask = "是否确定删除节点:{$vo2.name}"  data-action-method = "post">删除</a>
                            {/if}
                        </td>
                    </tr>
                    {notempty name="vo2.sub"}
                        {volist name="vo2.sub" id="vo3"}
                        <tr>
                            <td>{if condition="!empty($vo3.icon) and $vo3.icon neq '#'"}<i class = "{$vo3.icon}"/>{/if}</td>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--{$vo3.name}</td>
                            <td>{$node_types[$vo3.type]}</td>
                            <td>{$node_status[$vo3.status]}</td>
                            <td>{$vo3.rule}</td>
                            <td>{$vo3.sort}</td>
                            <td>{$vo3.remark}</td>
                            <td>
                                {if hasAuth('admin/menu/edit')}
                                <span class="text-explode">|</span>
                                <a class = "user-option" data-action = "dialog" data-action-url="{:url('admin/menu/edit',['id'=>$vo3.id])}" >编辑</a>
                                {/if}
                                {if hasAuth('admin/menu/forbid')}
                                <span class="text-explode">|</span>
                                {if condition="$vo3.status eq 1"}
                                <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/forbid')}"
                                   data-action-params = '{"id":{$vo3.id},"field":"status","value":2}' data-action-method = "post">禁用</a>
                                {else}
                                <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/forbid')}"
                                   data-action-params = '{"id":{$vo3.id},"field":"status","value":1}' data-action-method = "post">启用</a>
                                {/if}
                                {/if}
                                {if hasAuth('admin/menu/del')}
                                <span class="text-explode">|</span>
                                <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/menu/del')}"
                                   data-action-params = '{"id":{$vo3.id},"field":"delete"}' data-action-ask = "是否确定删除节点:{$vo3.name}" data-action-method = "post">删除</a>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                    {/notempty}
                    {/volist}
                {/notempty}
                {/volist}
            {/notempty}
            {/volist}
            {/if}
        </tbody>
    </table>
</form>

{/block}